import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,4,5,6};
        int l=0,r=arr.length-1;

        while (l<r) {
            int tmep = 0;
            while (l < r && arr[l] % 2 != 0){
                l++;
            }
            while(l<r&&arr[r]%2==0){
                r--;
            }

                if (l < r) {
                    tmep = arr[l];
                    arr[l] = arr[r];
                    arr[r] = tmep;
                    l++;
                    r--;
                }
        }
        System.out.println(Arrays.toString(arr));
    }
}